fix: fp-check Stop hooks return JSON instead of plain text#137
fix: fp-check Stop hooks return JSON instead of plain text#137bluzername wants to merge 1 commit intotrailofbits:mainfrom
Conversation
|
|
Automated Review — PR #137Flagged for human review (touches hooks) Review FindingsThe fix is correct and addresses a real bug. Issue #131 documents that prompt-type Stop/SubagentStop hooks must return JSON with a Changes reviewed:
Correctness assessment:
Potential concern — version not bumped:
No security concerns. The hooks only inspect conversation content and return approve/block decisions — no file system access, no command execution, no data exfiltration vectors. Validation
Changes MadeNone — review-only for complex PRs. Reviewed by Claude Code |
|
@bluzername please sign the CLA so we can consider this contribution! Thanks. |
Problem
The fp-check plugin's Stop and SubagentStop hooks cause "JSON validation failed" error every time Claude Code exits a session. The hooks use
type: "prompt"which expects the LLM to return structured JSON, but the prompt instructions tell it to return plain text like'approve'or'block'.I was getting this error on every session exit after installing fp-check and it was confusing because the plugin wasnt even being used in those sessions.
Root Cause
In
plugins/fp-check/hooks/hooks.json, both hooks have prompts ending with:But Claude Code expects prompt-type hooks to return valid JSON like:
{"decision": "approve"}Fix
Updated the return instructions in both hooks to ask for JSON format:
Stop hook (line 10):
SubagentStop hook (line 22):
Same pattern.
Also added
IMPORTANT: Return valid JSON only, no text outside the JSON object.to both prompts to make sure the LLM doesnt add extra text around the JSON.Impact
This error happens on EVERY session exit when fp-check is installed, even for sessions that have nothing to do with false positive verification. The fix makes both hooks return proper JSON so Claude Code can parse the response correctly.
Closes #131